package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicProGetDAO;
import com.cssy.yd.logic.entity.LogicProGetDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-12
 */
public class LogicProGetDAOImpl extends SqlMapClientDaoSupport implements LogicProGetDAO {

    /**
     * 插入数据
     * @param logicProGetDO
     * @return 插入数据的主键
     */
    public String insertLogicProGetDO(LogicProGetDO logicProGetDO) throws DataAccessException {
    	logicProGetDO.setVarsion(1);
        Object id = getSqlMapClientTemplate().insert("LogicProGet.insert", logicProGetDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicProGetDO
     * @return 查出的记录数
     */
    public Integer countLogicProGetDOByExample(LogicProGetDO logicProGetDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProGet.countByDOExample", logicProGetDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicProGetDO
     * @return 受影响的行数
     */
    public Integer updateLogicProGetDO(LogicProGetDO logicProGetDO) throws DataAccessException {
    	logicProGetDO.setVarsionbt(logicProGetDO.getVarsion());
    	logicProGetDO.setVarsion(logicProGetDO.getVarsion()+1);
    	int result = getSqlMapClientTemplate().update("LogicProGet.update", logicProGetDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicProGetDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicProGetDO> findListByExample(LogicProGetDO logicProGetDO) throws DataAccessException {
        List<LogicProGetDO> list = getSqlMapClientTemplate().queryForList("LogicProGet.findListByDO", logicProGetDO);
        return list;
    }

    /**
     * 根据主键获取logicProGetDO
     * @param id
     * @return logicProGetDO
     */
    public LogicProGetDO findLogicProGetDOByPrimaryKey(String id) throws DataAccessException {
        LogicProGetDO logicProGetDO = (LogicProGetDO) getSqlMapClientTemplate().queryForObject("LogicProGet.findByPrimaryKey", id);
        return logicProGetDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicProGetDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProGet.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicProGetDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicProGetDO> list = getSqlMapClientTemplate().queryForList("LogicProGet_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProGet_ex.count", scs);
			return count;
	}

}